﻿using FetchesDeploy.Distributed.Factory;
using Microsoft.AspNetCore.Mvc;

namespace FetchesDeploy.ScalableFactoryUnit.Controllers
{
    /// <summary>
    /// Fetcher api是container独有的
    /// </summary>
    [Route("[controller]")]
    [ApiController]
    public class FetcherController : ControllerBase
    {
        [HttpPost("{fetcherId}")]
        public ActionResult DispatchFetcher(long fetcherId)
        {
            FetchFactoryUnit.Instance().DispatchFetcher(fetcherId);
            return Ok($"fetcher is dispatched to {FetchFactoryUnit.Instance().FactoryId}");
        }

        [HttpDelete("{fetcherId}")]
        public ActionResult DismissFetcher(long fetcherId)
        {
            FetchFactoryUnit.Instance().DismissFetcher(fetcherId);
            return Ok($"fetcher {fetcherId} on {FetchFactoryUnit.Instance().FactoryId} is dismissed");
        }
    }
}
